package com.net.wanjian.networkhospitalmanager.activity.teacherevent;

import android.graphics.Color;
import android.graphics.drawable.PaintDrawable;
import android.support.v7.widget.LinearLayoutManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.net.wanjian.networkhospitalmanager.R;
import com.net.wanjian.networkhospitalmanager.activity.base.BaseActivity;
import com.net.wanjian.networkhospitalmanager.adapter.FirstListDepartmentAdapter;
import com.net.wanjian.networkhospitalmanager.adapter.SecondListDepartmentAdapter;
import com.net.wanjian.networkhospitalmanager.adapter.TeacherEventAdapter;
import com.net.wanjian.networkhospitalmanager.bean.teacherevent.DepartmentListResult;
import com.net.wanjian.networkhospitalmanager.bean.teacherevent.SearchEducatiationByConditionResult;
import com.net.wanjian.networkhospitalmanager.consts.AppConsts;
import com.net.wanjian.networkhospitalmanager.consts.ErrorCodeReturn;
import com.net.wanjian.networkhospitalmanager.net.HttpUtil;
import com.net.wanjian.networkhospitalmanager.netstatus.NetUtils;
import com.net.wanjian.networkhospitalmanager.utils.SharedXmlUtil;
import com.net.wanjian.networkhospitalmanager.utils.URLDecoderUtil;
import com.net.wanjian.networkhospitalmanager.view.LPopupWindow;
import com.net.wanjian.networkhospitalmanager.view.NoDataEmptyView;
import com.net.wanjian.networkhospitalmanager.widge.RefreshRecyclerView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import io.reactivex.observers.DisposableObserver;

public class TeacherEventActivity extends BaseActivity implements View.OnClickListener {
    public static final String SEARCHKEY = "com.wanjian.network.teachereventactivity.searchkey";
    private final String FIRST_POSITION_KEY = "first_position_key";
    private final String SECOND_POSITION_KEY = "second_position_key";

    @BindView(R.id.top_back_layout)
    LinearLayout topBackLayout;
    @BindView(R.id.teacher_event_search_iv)
    ImageView teacherEventSearchIv;
    @BindView(R.id.teacher_event_department_name_tv)
    TextView teacherEventDepartmentNameTv;
    @BindView(R.id.teacher_event_department_name_iv)
    ImageView teacherEventDepartmentNameIv;
    @BindView(R.id.teacher_event_department_layout)
    RelativeLayout teacherEventDepartmentLayout;
    @BindView(R.id.teacher_event_recycler_list)
    RefreshRecyclerView teacherEventRecyclerList;
    @BindView(R.id.teacher_event_progress)
    ProgressBar teacherEventProgress;
    @BindView(R.id.no_data_layout)
    NoDataEmptyView noDataLayout;
    @BindView(R.id.teacher_event_department_relative)
    RelativeLayout mDepartmentRelativeLayout;

    private TeacherEventAdapter teacherEventAdapter;
    private LPopupWindow mPopupWindow;
    private ListView leftListView;
    private ListView rightListView;

    private List<DepartmentListResult.DataBean.DepartmentListBean> mFirstList;
    private List<DepartmentListResult.DataBean.DepartmentListBean.SecondDepartmentListBean> mSecondList;
    private List<SearchEducatiationByConditionResult.DataBean.EducationActivityListBean> educationActivityList;
    private int currentNum = AppConsts.currentPageNum, currentPageNum, countNum;


    @Override
    protected void initData() {

        //本地模拟数据 加载listview的
        // 初始化默认医院选择为0，全部
        SharedXmlUtil.getInstance().write(FIRST_POSITION_KEY, 0);
        SharedXmlUtil.getInstance().write(SECOND_POSITION_KEY, 0);
        mFirstList = new ArrayList<>();

        List<DepartmentListResult.DataBean.DepartmentListBean.SecondDepartmentListBean> m2List;
        m2List = new ArrayList<>();
        DepartmentListResult.DataBean.DepartmentListBean d = new DepartmentListResult.DataBean.DepartmentListBean();
        d.setDepartmentID("0");
        d.setDepartmentName("科室");

        DepartmentListResult.DataBean.DepartmentListBean.SecondDepartmentListBean b = new DepartmentListResult.DataBean.DepartmentListBean.SecondDepartmentListBean();
        b.setDepartmentID("0");
        b.setDepartmentName("全部科室");
        m2List.add(b);

        d.setSecondDepartmentList(m2List);
        mFirstList.add(d);

//        mFirstList = new ArrayList<>();
//        List<DepartmentListResult.DataBean.DepartmentListBean.SecondDepartmentListBean> m2List;
//        for (int i = 0; i < 10; i++) {
////            if (i==0){
//                m2List = new ArrayList<>();
//                DepartmentListResult.DataBean.DepartmentListBean d = new DepartmentListResult.DataBean.DepartmentListBean();
//                d.setDepartmentID("0");
//                d.setDepartmentName("科室");
//
//                DepartmentListResult.DataBean.DepartmentListBean.SecondDepartmentListBean b = new DepartmentListResult.DataBean.DepartmentListBean.SecondDepartmentListBean();
//                b.setDepartmentID("0");
//                b.setDepartmentName("全部科室");
//                m2List.add(b);
//
//                d.setSecondDepartmentList(m2List);
//                mFirstList.add(d);
//            }else {
//                m2List = new ArrayList<>();
//                DepartmentListResult.DataBean.DepartmentListBean d = new DepartmentListResult.DataBean.DepartmentListBean();
//                d.setDepartmentID("2"+i);
//                d.setDepartmentName("内科外科"+i);
//                for (int j = 0; j < 59; j++) {
//                    if (i%2==0){
//                        DepartmentListResult.DataBean.DepartmentListBean.SecondDepartmentListBean b = new DepartmentListResult.DataBean.DepartmentListBean.SecondDepartmentListBean();
//                        b.setDepartmentID("3"+j);
//                        b.setDepartmentName("消化科方向"+j);
//                        m2List.add(b);
//                    }else {
//                        DepartmentListResult.DataBean.DepartmentListBean.SecondDepartmentListBean b = new DepartmentListResult.DataBean.DepartmentListBean.SecondDepartmentListBean();
//                        b.setDepartmentID("ceshi"+j);
//                        b.setDepartmentName("五官科"+j);
//                        m2List.add(b);
//                    }
//
//                }
//                d.setSecondDepartmentList(m2List);
//                mFirstList.add(d);
//            }

//        }


        topBackLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                TeacherEventActivity.this.finish();
            }
        });

        teacherEventSearchIv.setOnClickListener(this);
        teacherEventDepartmentLayout.setOnClickListener(this);

        noDataLayout.setNoData(R.string.no_teacher_event_text);
        noDataLayout.setOnReLoadClickListener(new NoDataEmptyView.OnReLoadClickListener() {
            @Override
            public void onReloadClick(View v) {
                //获取当前选择的科室
                int position1 = SharedXmlUtil.getInstance().read(FIRST_POSITION_KEY, 0);
                int position2 = SharedXmlUtil.getInstance().read(SECOND_POSITION_KEY, 0);
                handleResult(mFirstList.get(position1).getDepartmentID(),
                        mFirstList.get(position1).getSecondDepartmentList().get(position2).getDepartmentID(),
                        mFirstList.get(position1).getSecondDepartmentList().get(position2).getDepartmentName());
            }
        });
        teacherEventRecyclerList.setEmptyView(noDataLayout);
        teacherEventRecyclerList.setRefreshMode(3);
        teacherEventRecyclerList.addOnRefreshListener(new RefreshRecyclerView.OnRefreshListener() {
            @Override
            public void onRefresh() {
                //获取当前选择的科室
                int position1 = SharedXmlUtil.getInstance().read(FIRST_POSITION_KEY, 0);
                int position2 = SharedXmlUtil.getInstance().read(SECOND_POSITION_KEY, 0);
                handleResult(mFirstList.get(position1).getDepartmentID(),
                        mFirstList.get(position1).getSecondDepartmentList().get(position2).getDepartmentID(),
                        mFirstList.get(position1).getSecondDepartmentList().get(position2).getDepartmentName());
            }

            @Override
            public void onLoadMore() {
                loadMore();
            }
        });
        teacherEventRecyclerList.setLayoutManager(new LinearLayoutManager(this));

        getDepartmentListHttpRequest();
//        teacherEventRecyclerList.refresh();

    }

    //加载更多，根据当前科室
    private void loadMore() {
        //获取当前选择的科室
        int position1 = SharedXmlUtil.getInstance().read(FIRST_POSITION_KEY, 0);
        int position2 = SharedXmlUtil.getInstance().read(SECOND_POSITION_KEY, 0);

        String firstId = mFirstList.get(position1).getDepartmentID();
        String secondId = mFirstList.get(position1).getSecondDepartmentList().get(position2).getDepartmentID();

        //为0即为全部科室，不需要传递科室id
        if (firstId.equals("0") && secondId.equals("0")) {
            searchConditionLoadMore(firstId, 2);
        } else if (!firstId.equals("0") && secondId.equals("0")) {
            searchConditionLoadMore(firstId, 3);
        } else if (!firstId.equals("0") && !secondId.equals("0")) {
            searchConditionLoadMore(secondId, 3);
        }

    }

    private void searchConditionLoadMore(String departmentID, int queryType) {
        currentPageNum++;
        teacherEventProgress.setVisibility(View.VISIBLE);
        SharedXmlUtil xmlUtil = SharedXmlUtil.getInstance();
        HttpUtil.SearchEducatiationActivityByCondition(xmlUtil.getDeviceId(), xmlUtil.getToken(), xmlUtil.getHospitalId(),
                departmentID, queryType, currentPageNum, currentNum, new DisposableObserver<SearchEducatiationByConditionResult>() {
                    @Override
                    public void onNext(SearchEducatiationByConditionResult searchEducatiationByConditionResult) {
                        if (searchEducatiationByConditionResult.getResult() == ErrorCodeReturn.success) {
                            SharedXmlUtil.getInstance().setToken(URLDecoderUtil.getDecoder(searchEducatiationByConditionResult.getData().getToken()));
                            educationActivityList.addAll(searchEducatiationByConditionResult.getData().getEducationActivityList());
                            teacherEventAdapter.setList(educationActivityList);

                            if (searchEducatiationByConditionResult.getData().getEducationActivityList().size() < currentNum || educationActivityList.size() >= countNum) {
                                teacherEventRecyclerList.setNoMore(true);
                            } else {
                                teacherEventRecyclerList.loadMoreComplete();
                            }
                        }else {
                            teacherEventRecyclerList.loadMoreComplete();
                        }
                    }

                    @Override
                    public void onError(Throwable e) {
                        teacherEventProgress.setVisibility(View.GONE);
                        teacherEventRecyclerList.loadMoreComplete();

                    }

                    @Override
                    public void onComplete() {
                        teacherEventProgress.setVisibility(View.GONE);

                    }
                });
    }


    private void getDepartmentListHttpRequest() {
        SharedXmlUtil xmlUtil = SharedXmlUtil.getInstance();
        HttpUtil.getDepartmentList(xmlUtil.getDeviceId(), xmlUtil.getToken(), xmlUtil.getHospitalId(), new DisposableObserver<DepartmentListResult>() {
            @Override
            public void onNext(DepartmentListResult departmentListResult) {
                if (departmentListResult.getResult() == ErrorCodeReturn.success) {

                    List<DepartmentListResult.DataBean.DepartmentListBean> departmentList = departmentListResult.getData().getDepartmentList();
                    int size = departmentList.size();

                    List<DepartmentListResult.DataBean.DepartmentListBean.SecondDepartmentListBean> m2List;
                    for (int i = 0; i <= size; i++) {
                        if (i != 0){
                            List<DepartmentListResult.DataBean.DepartmentListBean.SecondDepartmentListBean> secondDepartmentList = departmentList.get(i - 1).getSecondDepartmentList();
                            int size2 = secondDepartmentList.size();
                            m2List = new ArrayList<>();
                            DepartmentListResult.DataBean.DepartmentListBean d = new DepartmentListResult.DataBean.DepartmentListBean();
                            d.setDepartmentID(departmentList.get(i - 1).getDepartmentID());
                            d.setDepartmentName(departmentList.get(i - 1).getDepartmentName());
                            for (int j = 0; j <= size2; j++) {
                                if (j == 0) {
                                    DepartmentListResult.DataBean.DepartmentListBean.SecondDepartmentListBean b = new DepartmentListResult.DataBean.DepartmentListBean.SecondDepartmentListBean();
                                    b.setDepartmentID("0");
                                    b.setDepartmentName("全部" + URLDecoderUtil.getDecoder(departmentList.get(i - 1).getDepartmentName()));
                                    m2List.add(b);
                                } else {
                                    m2List.add(secondDepartmentList.get(j - 1));
                                }

                            }
                            d.setSecondDepartmentList(m2List);
                            mFirstList.add(d);
                        }

                    }

                }

                //
                getTeacherEventHttpRequest();
            }

            @Override
            public void onError(Throwable e) {
                teacherEventProgress.setVisibility(View.GONE);
            }

            @Override
            public void onComplete() {

            }
        });
    }

    //请求网络教学事件
    private void getTeacherEventHttpRequest() {
        currentPageNum = 0;
        SharedXmlUtil xmlUtil = SharedXmlUtil.getInstance();
        HttpUtil.SearchEducatiationActivityByCondition(xmlUtil.getDeviceId(), xmlUtil.getToken(), xmlUtil.getHospitalId(), null, 2, currentPageNum, currentNum, new DisposableObserver<SearchEducatiationByConditionResult>() {
            @Override
            public void onNext(SearchEducatiationByConditionResult searchEducatiationByConditionResult) {
                if (searchEducatiationByConditionResult.getResult() == ErrorCodeReturn.success) {
                    SharedXmlUtil.getInstance().setToken(URLDecoderUtil.getDecoder(searchEducatiationByConditionResult.getData().getToken()));
                    educationActivityList = searchEducatiationByConditionResult.getData().getEducationActivityList();
                    countNum = Integer.parseInt(URLDecoderUtil.getDecoder(searchEducatiationByConditionResult.getData().getEducationActivityCount()));
                    Log.e(TAG, "onNext: "+countNum );
                    initRecyclerList();

                    if (searchEducatiationByConditionResult.getData().getEducationActivityList().size() < currentNum || educationActivityList.size() >= countNum) {
                        teacherEventRecyclerList.setNoMore(true);
                    } else {
                        teacherEventRecyclerList.loadMoreComplete();
                    }
                }
            }

            @Override
            public void onError(Throwable e) {
                teacherEventProgress.setVisibility(View.GONE);
            }

            @Override
            public void onComplete() {
                teacherEventProgress.setVisibility(View.GONE);
            }
        });

    }

    //首次加载列表
    private void initRecyclerList() {
        teacherEventAdapter = new TeacherEventAdapter(this);
        teacherEventAdapter.setList(educationActivityList);
        teacherEventRecyclerList.setAdapter(teacherEventAdapter);
    }


    @Override
    protected int getLayoutId() {
        return R.layout.activity_teacher_event;
    }

    @Override
    protected void onNetworkConnected(NetUtils.NetType type) {
        noDataLayout.setNoData(R.string.no_teacher_event_text);
        teacherEventRecyclerList.setEmptyView(noDataLayout);
        getTeacherEventHttpRequest();
    }

    @Override
    protected void onNetworkDisConnected() {
        noDataLayout.setNoNetWork();
        teacherEventRecyclerList.setEmptyView(noDataLayout);
        teacherEventAdapter.notifyDataSetChanged();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.teacher_event_search_iv://搜索
//                openActivityForResult(SearchTeacherEventActivity.class, 22);
                openActivity(SearchTeacherEventActivity.class);
                break;
            case R.id.teacher_event_department_layout://popupwindow选择科室
                initPopupWindow();
                break;
        }
    }

   /* @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == 22) {
            if (null != data && resultCode == 33) {
                String key = data.getExtras().getString(SEARCHKEY);
                //这里用关键子搜索请求
                ToastUtil.showToast(key);
            }
        } else {
            super.onActivityResult(requestCode, resultCode, data);
        }

    }*/

    //加载poppup
    private void initPopupWindow() {
        mPopupWindow = new LPopupWindow(this);
        View view = LayoutInflater.from(this).inflate(R.layout.popup_window_teacher_event, null);
        leftListView = (ListView) view.findViewById(R.id.popup_window_teacher_event_listview_left);
        rightListView = (ListView) view.findViewById(R.id.popup_window_teacher_event_listview_right);
        View transView = view.findViewById(R.id.popup_trans_view);

//       将view添加到popup里面
        mPopupWindow.setContentView(view);
        mPopupWindow.setBackgroundDrawable(new PaintDrawable(Color.TRANSPARENT));
        mPopupWindow.setFocusable(true);

//        popupWindow消失的监听
        mPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                teacherEventDepartmentNameIv.setSelected(false);
            }
        });

        transView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mPopupWindow.dismiss();
            }
        });

        //获取当前选择的科室
        final int position1 = SharedXmlUtil.getInstance().read(FIRST_POSITION_KEY, 0);
        final int position2 = SharedXmlUtil.getInstance().read(SECOND_POSITION_KEY, 0);

        //加载一级分类
        final FirstListDepartmentAdapter firstAdapter = new FirstListDepartmentAdapter(this, mFirstList);
        firstAdapter.setSelectedPosition(position1);
        leftListView.setAdapter(firstAdapter);

        //加载左侧第一行对应右侧二级分类
        mSecondList = new ArrayList<>();
        /**
         * 这里有为null的bug
         */
        mSecondList.addAll(mFirstList.get(position1).getSecondDepartmentList());
        final SecondListDepartmentAdapter secondAdapter = new SecondListDepartmentAdapter(this, mSecondList);
        secondAdapter.setSelectedPosition(position2);
        rightListView.setAdapter(secondAdapter);

        //左侧ListView点击事件
        leftListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                //二级数据
                List<DepartmentListResult.DataBean.DepartmentListBean.SecondDepartmentListBean> list2 = mFirstList.get(position).getSecondDepartmentList();
                //如果没有二级类，则直接跳转
                if (list2 == null || list2.size() == 0) {
                    mPopupWindow.dismiss();

                    String firstId = mFirstList.get(position).getDepartmentID();
                    String selectedName = mFirstList.get(position).getDepartmentName();

                    handleResult(firstId, "-1", selectedName);
                    return;
                }

//                如果有二级联动的数据,那么 更新数据
                FirstListDepartmentAdapter adapter = (FirstListDepartmentAdapter) (parent.getAdapter());
                //如果上次点击的就是这一个item，则不进行任何操作
                if (adapter.getSelectedPosition() == position) {
                    return;
                }

                //根据左侧一级分类选中情况，更新背景色
                adapter.setSelectedPosition(position);
                adapter.notifyDataSetChanged();

                //显示右侧二级分类
                updateSecondListView(list2, secondAdapter, position, position1, position2);
            }

        });

        //右侧ListView点击事件
        rightListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                //关闭popupWindow，显示用户选择的分类
                mPopupWindow.dismiss();

                int firstPosition = firstAdapter.getSelectedPosition();

                //在这里保存选择的id
                SharedXmlUtil.getInstance().write(FIRST_POSITION_KEY, firstPosition);
                SharedXmlUtil.getInstance().write(SECOND_POSITION_KEY, position);

                String firstId = mFirstList.get(firstPosition).getDepartmentID();
                String secondId = mFirstList.get(firstPosition).getSecondDepartmentList().get(position).getDepartmentID();
                String selectedName = mFirstList.get(firstPosition).getSecondDepartmentList().get(position).getDepartmentName();
                //根据右侧二级分类选中情况，更新背景色
                SecondListDepartmentAdapter adapter = (SecondListDepartmentAdapter) parent.getAdapter();
                adapter.setSelectedPosition(position);
                adapter.setFirstPosition(firstPosition);
                adapter.notifyDataSetChanged();

                handleResult(firstId, secondId, selectedName);
            }
        });


        mPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                teacherEventDepartmentNameIv.setSelected(false);
//                    WindowManager.LayoutParams lp = getWindow().getAttributes();
//                    lp.alpha = 1f;
//                    getWindow().setAttributes(lp);
            }
        });


        //最后显示popupwindow
        if (mPopupWindow.isShowing()) {
            mPopupWindow.dismiss();

        } else {
//         在那个控件下面显示
            teacherEventDepartmentNameIv.setSelected(true);

            //产生背景变暗效果
//            WindowManager.LayoutParams lp = getWindow().getAttributes();
//            lp.alpha = 0.4f;
//            getWindow().setAttributes(lp);
            mPopupWindow.showAsDropDown(mDepartmentRelativeLayout);
        }
    }

    /**
     * 刷新右侧listview
     *
     * @param list2
     * @param secondAdapter
     * @param position
     */
    private void updateSecondListView(List<DepartmentListResult.DataBean.DepartmentListBean.SecondDepartmentListBean> list2, SecondListDepartmentAdapter secondAdapter, int position, int position1, int position2) {
        mSecondList.clear();
        mSecondList.addAll(list2);
        secondAdapter.setFirstCurrentPosition(position);
        secondAdapter.setFirstPosition(position1);
        secondAdapter.setSelectedPosition(position2);
        secondAdapter.notifyDataSetChanged();
    }

    private void handleResult(String firstId, String secondId, String selectedName) {
//        String text = "first id:" + firstId + ",second id:" + secondId+"选择的名字："+selectedName;
//        ToastUtil.showToast(text);
        teacherEventDepartmentNameTv.setText(URLDecoderUtil.getDecoder(selectedName));

        //为0即为全部科室，不需要传递科室id
        if (firstId.equals("0") && secondId.equals("0")) {
            searchCondition(firstId, 2);
        } else if (!firstId.equals("0") && secondId.equals("0")) {
            searchCondition(firstId, 3);
        } else if (!firstId.equals("0") && !secondId.equals("0")) {
            searchCondition(secondId, 3);
        }
    }

    /**
     * 条件查询科室返回的
     *
     * @param departmentID queryType为3设置科室id的值，如果为2传null即可
     * @param queryType    2 - 全部科室 3 - 具体科室
     */
    private void searchCondition(String departmentID, int queryType) {

        teacherEventProgress.setVisibility(View.VISIBLE);
        currentPageNum = 0;
        SharedXmlUtil xmlUtil = SharedXmlUtil.getInstance();
        HttpUtil.SearchEducatiationActivityByCondition(xmlUtil.getDeviceId(), xmlUtil.getToken(), xmlUtil.getHospitalId(), departmentID, queryType, currentPageNum, currentNum, new DisposableObserver<SearchEducatiationByConditionResult>() {
            @Override
            public void onNext(SearchEducatiationByConditionResult searchEducatiationByConditionResult) {
                if (searchEducatiationByConditionResult.getResult() == ErrorCodeReturn.success) {
                    SharedXmlUtil.getInstance().setToken(URLDecoderUtil.getDecoder(searchEducatiationByConditionResult.getData().getToken()));
                    educationActivityList = searchEducatiationByConditionResult.getData().getEducationActivityList();
                    teacherEventAdapter.setList(educationActivityList);

                    if (searchEducatiationByConditionResult.getData().getEducationActivityList().size() < currentNum || educationActivityList.size() >= countNum) {
                        teacherEventRecyclerList.refreshComplete();
                        teacherEventRecyclerList.setNoMore(true);
                    } else {
                        teacherEventRecyclerList.refreshComplete();
                        teacherEventRecyclerList.setNoMore(false);
                    }
                }
            }

            @Override
            public void onError(Throwable e) {
                teacherEventProgress.setVisibility(View.GONE);
                teacherEventRecyclerList.refreshComplete();

            }

            @Override
            public void onComplete() {
                teacherEventProgress.setVisibility(View.GONE);

            }
        });
    }


}
